import pytest
import requests
from 接口自动化.send.Send import Send
from 接口自动化.utils.read_yaml import read_yaml
class TestLoan:

    @pytest.mark.parametrize( "args" ,  read_yaml("../data/loan.yaml")  )
    def test_loan(self,args):

        name = args["username"]
        pwd= args["pwd"]
        session  = requests.session()

        se = Send()
        login = se.send_login(session,name,pwd)
        print(login["body"]["code"])

        amount = args["amount"]
        term= args["term"]
        rate = args["rate"]
        exp = args["exp"]
        result = se.send_loan(session,amount,term,rate)

        assert result["code"] == 200 and result["body"]["code"] == exp
